import vue from '@vitejs/plugin-vue'
import { resolve } from 'path';
import { defineConfig } from 'vite'

import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'


// https://vitejs.dev/config/
const pathResolve = (dir: string): any => {
	return resolve(__dirname, '.', dir);
};

const alias: Record<string, string> = {
	'@': pathResolve('./src')
};

export default defineConfig({
  resolve: {
    alias
  },
  plugins: [
    vue(),
    // 按需加载样式有问题
    // AutoImport({
    //   resolvers: [ElementPlusResolver()],
    // }),
    // Components({
    //   resolvers: [ElementPlusResolver()],
    // })
  ],
  server: {
    port: 3000,
    open: true,
    proxy: {
      '/api': {
        target: 'http://10.200.52.122:8000',
        changeOrigin: true,
        rewrite: (path) =>  path.replace(/^\api/, '')
      }
    }
  }

})
